package seven.test_7_25;

import java.util.ArrayList;

public class Solution {
    public String formatString (String str, char[] arg) {
        // write code here
        StringBuilder result = new StringBuilder();
        int j = 0;
        for (int i = 0; i < str.length(); i++) {
            char c = str.charAt(i);
            if(c == '%' && i < str.length() && str.charAt(i + 1) == 's') {
                result.append(arg[j]);
                j++;
                i++;
            } else {
                result.append(c);
            }
        }
        while (j < arg.length) {
            result.append(arg[j]);
            j++;
        }
        return result.toString();
    }
}
